/*
 *  BlowFish.h
 *  TubeTruck
 *
 *  Created by Aeturnum on 5/21/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#pragma once

#include "EKey.h"
#include <vector>
#include "TubeTruckTypes.h"
#include <openssl/evp.h>
#include <openssl/err.h>
#include <assert.h>
#include "Encryptable.h"
#include "util.h"


namespace TTP {
   namespace Crypt {
      class BlowFish : public EKey {
      protected:
         std::vector<byte> mBlowFishKey, mBlowFishIv; // 128 bits (16 bytes)
         
         void generateRandomKey();
         void generateRandomIv();
         
      public:
         
         enum{BlowFish_KeySize = 16, BlowFish_IvSize = 8};
         
         BlowFish();
         BlowFish(std::vector<byte>&, std::vector<byte>&);
         virtual ~BlowFish();
         BlowFish(const BlowFish&);
         
         std::vector<byte> encrypt(const std::vector<byte>&);
         std::vector<byte> decrypt(const std::vector<byte>&);
         void encrypt(Encryptable&);
         void decrypt(Encryptable&);
         
         void setIv(std::vector<byte>&);
         std::vector<byte> getIv();
         
         void setKey(std::vector<byte>&);
         std::vector<byte> getKey();
      };
   }
}